import Vue from "vue";
import Router from "vue-router";

const originalPush = Router.prototype.push;

Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => {
    // console.log('路由错误: ', err)
  });
};

Vue.use(Router);

/* Layout */
// import Layout from '@/layout/index'
import Layout from "@/layout/layout.js";
import ParentView from "@/components/ParentView";

/**
 * Note: 路由配置项
 *
 * hidden: true                   // 当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
 * alwaysShow: true               // 当你一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式--如组件页面
 *                                // 只有一个时，会将那个子路由当做根路由显示在侧边栏--如引导页面
 *                                // 若你想不管路由下面的 children 声明的个数都显示你的根路由
 *                                // 你可以设置 alwaysShow: true，这样它就会忽略之前定义的规则，一直显示根路由
 * redirect: noRedirect           // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 * name:'router-name'             // 设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题
 * meta : {
    noCache: true                // 如果设置为true，则不会被 <keep-alive> 缓存(默认 false)
    title: 'title'               // 设置该路由在侧边栏和面包屑中展示的名字
    icon: 'svg-name'             // 设置该路由的图标，对应路径src/assets/icons/svg
    breadcrumb: false            // 如果设置为false，则不会在breadcrumb面包屑中显示
  }
 */

// 公共路由
export const constantRoutes = [
  {
    path: "/",
    redirect: "/riskScene/index",
    hidden: true,
  },
  {
    path: "/index",
    redirect: "/riskScene/index",
    hidden: true,
  },

  // {
  //   path: '/sample',
  //   component: (resolve) => require(['@/views/sample/index'], resolve),
  //   hidden: true
  // },
  // {
  //   path: "/false",
  //   component: (resolve) => require(["@/views/system/menu/index"], resolve),
  //   hidden: true,
  // },
  // //告警详情（甘肃 第三方）
  // {
  //   path: "/tmpAlarmInfo",
  //   component: (resolve) => require(["@/views/system/alarm/index"], resolve),
  //   hidden: false,
  // },
  // //api敏感报告详情（甘肃 第三方）
  // {
  //   path: "/tmpApiReport",
  //   component: (resolve) =>
  //     require(["@/views/apisecurity/apiReport/components/detailTab"], resolve),
  //   hidden: false,
  // },
  // //数据库资产敏感报告详情（甘肃 第三方）
  // {
  //   path: "/tmpAssetsReport",
  //   component: (resolve) =>
  //     require([
  //       "@/views/datascan/dataAssetsReport/components/detailTab",
  //     ], resolve),
  //   hidden: true,
  // },
  // {
  //   path: "/authorizeMenu",
  //   component: (resolve) =>
  //     require(["@/views/system/authorizeMenu/index"], resolve),
  //   hidden: true,
  // },
  // {
  //   path: "/license",
  //   component: (resolve) => require(["@/views/system/license/index"], resolve),
  //   hidden: true,
  // },
  // {
  //   path: "/icons",
  //   component: (resolve) => require(["@/views/system/icons/index"], resolve),
  //   hidden: true,
  // },
  // {
  //   path: "/1",
  //   component: (resolve) =>
  //     require(["@/views/apisecurity/sensitiveDataAuditing/index"], resolve),
  //   hidden: true,
  // },
  {
    path: "/login",
    component: (resolve) => require(["@/views/login"], resolve),
    hidden: true,
  },
  // {
  //   path: "/404",
  //   component: (resolve) => require(["@/views/error/404"], resolve),
  //   hidden: true,
  // },
  {
    path: "/403",
    component: (resolve) => require(["@/views/error/403"], resolve),
    hidden: true,
  },
  // {
  //   path: "/500",
  //   component: (resolve) => require(["@/views/error/500"], resolve),
  //   hidden: true,
  // },
  // {
  //   path: "/unauthorized",
  //   component: (resolve) => require(["@/views/error/unauthorized"], resolve),
  //   hidden: true,
  // },
  // {
  //   path: "/applicationType",
  //   component: (resolve) =>
  //     require(["@/views/apisecurity/applicationType/index"], resolve),
  //   hidden: true,
  // },
  // 强制刷新当前页所用的中间跳转页
  {
    path: "/redirect/:path*",
    component: () => import("@/views/redirect"),
    hidden: true,
  },
  // {
  //   path: "/personal",
  //   component: Layout,
  //   hidden: false,
  //   // meta: {
  //   //   title: "个人中心",
  //   //   noCache: true,
  //   //   affix: true,
  //   // },
  //   redirect: "/personal/personalCenter",
  //   children: [
  //     {
  //       path: "personalCenter",
  //       component: (resolve) =>
  //         require(["@/views/system/user/profile/index"], resolve),
  //       name: "个人中心",
  //       meta: {
  //         title: "个人中心",
  //         icon: "iconfont icon-yonghu",
  //         noCache: true,
  //         affix: true,
  //       },
  //     },
  //   ],
  // },
  // {
  //   path: "/approval",
  //   component: (resolve) =>
  //     require(["@/views/management/approval/index"], resolve),
  //   hidden: true,
  // },
  // {
  //   path: "/usermgr",
  //   component: Layout,
  //   // redirect: "/usermgr/index",
  //   children: [
  //     {
  //       path: "index",
  //       name: "usermgr",
  //       component: () => import("@/views/management/user/user/index"),
  //       meta: { title: "用户管理", icon: "user", affix: true },
  //     },
  //   ],
  // },
  // {
  //   path: "/resource",
  //   component: Layout,
  //   // redirect: "/usermgr/index",
  //   meta: {
  //     title: "资源管理",
  //     icon: "database",
  //   },
  //   children: [
  //     {
  //       path: "resource",
  //       name: "resource",
  //       component: () => import("@/views/management/resource/index"),
  //       meta: { title: "资源管理", affix: false },
  //     },
  //     {
  //       path: "account",
  //       name: "accountNumber",
  //       component: () => import("@/views/management/accountNumber/index"),
  //       meta: { title: "从账号管理", affix: false },
  //     },
  //   ],
  // },
  // {
  //   path: "/right",
  //   component: Layout,
  //   // redirect: "/usermgr/index",
  //   // meta: {
  //   //   title: "授权管理",
  //   //   // icon: "safety-certificate",
  //   // },
  //   children: [
  //     {
  //       path: "index",
  //       name: "right",
  //       component: () => import("@/views/management/right/index"),
  //       meta: { title: "授权管理", icon: "shouquan", affix: false },
  //     },
  //   ],
  // },
  // {
  //   path: "/jinku",
  //   component: Layout,
  //   redirect: "/jinku/index",
  //   meta: {
  //     title: "金库管控",
  //     icon: "jinku",
  //   },
  //   children: [
  //     {
  //       path: "index",
  //       name: "jinku",
  //       component: () => import("@/views/management/jinku/list/index"),
  //       meta: { title: "审批列表" },
  //     },
  //     {
  //       path: "rule",
  //       name: "rule",
  //       component: () => import("@/views/management/jinku/rule/index"),
  //       meta: { title: "管控规则" },
  //     },
  //     {
  //       path: "log",
  //       name: "log",
  //       component: () => import("@/views/management/jinku/log/index"),
  //       meta: { title: "审批日志" },
  //     },
  //   ],
  // },
  // {
  //   path: "/session",
  //   component: Layout,
  //   hidden: false,
  //   children: [
  //     {
  //       path: "index",
  //       name: "session",
  //       component: () => import("@/views/management/session/index"),
  //       meta: { title: "会话管理", icon: "huihua" },
  //     },
  //   ],
  // },
  // {
  //   path: "/watermark",
  //   component: Layout,
  //   hidden: false,
  //   children: [
  //     {
  //       path: "index",
  //       name: "watermark",
  //       component: () => import("@/views/management/watermark/index"),
  //       meta: { title: "水印管理", icon: "shuiyin" },
  //     },
  //   ],
  // },
  // {
  //   path: "/logmgr",
  //   component: Layout,
  //   hidden: false,
  //   redirect: "/logmgr/action",
  //   meta: {
  //     title: "日志管理",
  //     icon: "rizhi",
  //   },
  //   children: [
  //     {
  //       path: "action",
  //       name: "action",
  //       component: () => import("@/views/management/logmgr/action/index"),
  //       // meta: { title: "日志管理", icon: "rizhiguanli1" },
  //       meta: { title: "操作日志", affix: false },
  //     },
  //     {
  //       path: "auth",
  //       name: "auth",
  //       component: () => import("@/views/management/logmgr/auth/index"),
  //       meta: { title: "认证日志", affix: false },
  //     },
  //   ],
  // },
  {
    path: "/riskScene",
    component: Layout,
    hidden: false,
    meta: {
      title: "风险模型",
      icon: "riskScene",
    },
    children: [
      {
        path: "index",
        name: "watermark",
        component: () => import("@/views/xinren/riskmodel/riskScene/index"),
        meta: { title: "风险场景", icon: "riskScene1", affix: true },
      },
      {
        path: "rule",
        name: "rule",
        component: () => import("@/views/xinren/riskmodel/riskRule/index"),
        meta: { title: "风险规则", icon: "riskRule" },
      },
      {
        path: "integration",
        name: "integration",
        component: () => import("@/views/xinren/riskmodel/integration/index1"),
        meta: { title: "积分管理", icon: "riskintegration" },
      },
    ],
  },
  {
    path: "/trustModel",
    component: Layout,
    hidden: false,
    meta: {
      title: "信任模型",
      icon: "xinren",
    },
    children: [
      {
        path: "index",
        name: "trustModel",
        component: () => import("@/views/xinren/trustModel/index"),
        meta: { title: "信任模型", icon: "xinren" },
      },
      {
        path: "decision",
        name: "decision",
        component: () => import("@/views/xinren/trustModel/decision/index"),
        meta: { title: "决策管理", icon: "juece" },
      },
      // {
      //   path: "business",
      //   name: "business",
      //   component: () => import("@/views/xinren/trustModel/business/index"),
      //   meta: { title: "精细化业务管控", icon: "jingxihua" },
      // },
    ],
  },
  {
    path: "/keshi",
    component: Layout,
    hidden: false,
    meta: {
      title: "可视化分析",
      icon: "keshihua",
    },
    children: [
      {
        path: "userInfo",
        name: "userInfo",
        component: () => import("@/views/xinren/keshi/userInfo/index"),
        meta: { title: "用户信息", icon: "user" },
      },
      // {
      //   path: "area",
      //   name: "area",
      //   component: () => import("@/views/xinren/keshi/area/index"),
      //   meta: { title: "风险地图", icon: "fengxianditu" },
      // },
      // {
      //   path: "center",
      //   name: "center",
      //   component: () => import("@/views/xinren/keshi/index"),
      //   meta: { title: "告警中心", icon: "shuiyin" },
      // },
      {
        path: "baobiao",
        name: "baobiao",
        component: () => import("@/views/xinren/keshi/index"),
        meta: { title: "报表中心", icon: "rizhi" },
      },
      // {
      //   path: "shenji",
      //   name: "shenji",
      //   component: () => import("@/views/xinren/keshi/locus/index"),
      //   meta: { title: "审计链路", icon: "liucheng" },
      // },
    ],
  },
  {
    path: "/safety",
    component: Layout,
    hidden: true,
    // meta: {
    //   title: "账号安全",
    //   noCache: true,
    //   affix: true,
    // },
    redirect: "/safety/index",
    children: [
      {
        path: "index",
        component: (resolve) =>
          require(["@/views/system/user/account/index"], resolve),
        name: "账号安全",
        meta: {
          title: "账号安全",
          icon: "iconfont icon-yonghu",
          noCache: true,
          affix: false,
        },
      },
    ],
  },
  {
    path: "/dictionMgn",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "index",
        name: "dictionMgn",
        component: () => import("@/views/management/dictionMgn/index"),
        meta: { title: "字典管理", icon: "zidianguanli-04" },
      },
    ],
  },

  // 找回密码
  // {
  //   path: "/findpwd",
  //   component: (resolve) =>
  //     require(["@/views/system/user/findpwd/index"], resolve),
  //   hidden: true,
  // },
  // 消息中心（消息列表）
  {
    path: "/msg",
    component: Layout,
    hidden: true,
    meta: {
      title: "消息中心",
      noCache: true,
      affix: true,
    },
    children: [
      {
        path: "index",
        component: (resolve) =>
          require(["@/views/msgService/mymsg/index"], resolve),
        name: "消息中心",
        meta: {
          title: "消息中心",
          icon: "iconfont icon-yonghu",
          noCache: true,
          affix: false,
        },
      },
    ],
  },
  {
    path: "/publicDetail",
    component: Layout,
    hidden: true,
    meta: {
      title: "公告详情",
      noCache: true,
      affix: true,
    },
    children: [
      {
        path: "index",
        component: (resolve) =>
          require(["@/views/msgService/publicDetail/index"], resolve),
        name: "公告详情",
        meta: {
          title: "公告详情",
          icon: "iconfont icon-yonghu",
          noCache: true,
          affix: false,
        },
      },
    ],
  },
];

export default new Router({
  mode: "history", // 去掉url中的#
  scrollBehavior: () => ({
    y: 0,
  }),
  routes: constantRoutes,
});
